<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>nixtransport.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_net_xpc_nixtransport.js.html">nixtransport.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line2"></a>// you may not use this file except in compliance with the License.
<a name="line3"></a>// You may obtain a copy of the License at
<a name="line4"></a>//
<a name="line5"></a>//     http://www.apache.org/licenses/LICENSE-2.0
<a name="line6"></a>//
<a name="line7"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line8"></a>// distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<a name="line9"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line10"></a>// See the License for the specific language governing permissions and
<a name="line11"></a>// limitations under the License.
<a name="line12"></a>
<a name="line13"></a>// Copyright 2008 Google Inc.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Contains the NIX (Native IE XDC) method transport for
<a name="line17"></a> * cross-domain communication. It exploits the fact that Internet Explorer
<a name="line18"></a> * allows a window that is the parent of an iframe to set said iframe window&#39;s
<a name="line19"></a> * opener property to an object. This object can be a function that in turn
<a name="line20"></a> * can be used to send a message despite same-origin constraints. Note that
<a name="line21"></a> * this function, if a pure JavaScript object, opens up the possibilitiy of
<a name="line22"></a> * gaining a hold of the context of the other window and in turn, attacking
<a name="line23"></a> * it. This implementation therefore wraps the JavaScript objects used inside
<a name="line24"></a> * a VBScript class. Since VBScript objects are passed in JavaScript as a COM
<a name="line25"></a> * wrapper (like DOM objects), they are thus opaque to JavaScript
<a name="line26"></a> * (except for the interface they expose). This therefore provides a safe
<a name="line27"></a> * method of transport.
<a name="line28"></a> *
<a name="line29"></a> *
<a name="line30"></a> * Initially based on FrameElementTransport which shares some similarities
<a name="line31"></a> * to this method.
<a name="line32"></a> */
<a name="line33"></a>
<a name="line34"></a>goog.provide(&#39;goog.net.xpc.NixTransport&#39;);
<a name="line35"></a>
<a name="line36"></a>goog.require(&#39;goog.net.xpc&#39;);
<a name="line37"></a>goog.require(&#39;goog.net.xpc.Transport&#39;);
<a name="line38"></a>
<a name="line39"></a>
<a name="line40"></a>
<a name="line41"></a>/**
<a name="line42"></a> * NIX method transport.
<a name="line43"></a> *
<a name="line44"></a> * NOTE: NIX method tested in all IE versions starting from 6.0.
<a name="line45"></a> *
<a name="line46"></a> * @param {goog.net.xpc.CrossPageChannel} channel The channel this transport
<a name="line47"></a> *     belongs to.
<a name="line48"></a> * @constructor
<a name="line49"></a> * @extends {goog.net.xpc.Transport}
<a name="line50"></a> */
<a name="line51"></a>goog.net.xpc.NixTransport = function(channel) {
<a name="line52"></a>  /**
<a name="line53"></a>   * The channel this transport belongs to.
<a name="line54"></a>   * @type {goog.net.xpc.CrossPageChannel}
<a name="line55"></a>   * @private
<a name="line56"></a>   */
<a name="line57"></a>  this.channel_ = channel;
<a name="line58"></a>
<a name="line59"></a>  /**
<a name="line60"></a>   * The authorization token, if any, used by this transport.
<a name="line61"></a>   * @type {string?}
<a name="line62"></a>   * @private
<a name="line63"></a>   */
<a name="line64"></a>  this.authToken_ = channel[goog.net.xpc.CfgFields.AUTH_TOKEN] || &#39;&#39;;
<a name="line65"></a>
<a name="line66"></a>  /**
<a name="line67"></a>   * The authorization token, if any, that must be sent by the other party
<a name="line68"></a>   * for setup to occur.
<a name="line69"></a>   * @type {string?}
<a name="line70"></a>   * @private
<a name="line71"></a>   */
<a name="line72"></a>  this.remoteAuthToken_ =
<a name="line73"></a>      channel[goog.net.xpc.CfgFields.REMOTE_AUTH_TOKEN] || &#39;&#39;;
<a name="line74"></a>
<a name="line75"></a>  // Conduct the setup work for NIX in general, if need be.
<a name="line76"></a>  goog.net.xpc.NixTransport.conductGlobalSetup_();
<a name="line77"></a>
<a name="line78"></a>  // Setup aliases so that VBScript can call these methods
<a name="line79"></a>  // on the transport class, even if they are renamed during
<a name="line80"></a>  // compression.
<a name="line81"></a>  this[goog.net.xpc.NixTransport.NIX_HANDLE_MESSAGE] = this.handleMessage_;
<a name="line82"></a>  this[goog.net.xpc.NixTransport.NIX_CREATE_CHANNEL] = this.createChannel_;
<a name="line83"></a>};
<a name="line84"></a>goog.inherits(goog.net.xpc.NixTransport, goog.net.xpc.Transport);
<a name="line85"></a>
<a name="line86"></a>
<a name="line87"></a>// Consts for NIX. VBScript doesn&#39;t allow items to start with _ for some
<a name="line88"></a>// reason, so we need to make these names quite unique, as they will go into
<a name="line89"></a>// the global namespace.
<a name="line90"></a>
<a name="line91"></a>/**
<a name="line92"></a> * Global name of the Wrapper VBScript class.
<a name="line93"></a> * Note that this class will be stored in the *global*
<a name="line94"></a> * namespace (i.e. window in browsers).
<a name="line95"></a> * @type {string}
<a name="line96"></a> */
<a name="line97"></a>goog.net.xpc.NixTransport.NIX_WRAPPER = &#39;GCXPC____NIXVBS_wrapper&#39;;
<a name="line98"></a>
<a name="line99"></a>
<a name="line100"></a>/**
<a name="line101"></a> * Global name of the GetWrapper VBScript function. This
<a name="line102"></a> * constant is used by JavaScript to call this function.
<a name="line103"></a> * Note that this function will be stored in the *global*
<a name="line104"></a> * namespace (i.e. window in browsers).
<a name="line105"></a> * @type {string}
<a name="line106"></a> */
<a name="line107"></a>goog.net.xpc.NixTransport.NIX_GET_WRAPPER = &#39;GCXPC____NIXVBS_get_wrapper&#39;;
<a name="line108"></a>
<a name="line109"></a>/**
<a name="line110"></a> * The name of the handle message method used by the wrapper class
<a name="line111"></a> * when calling the transport.
<a name="line112"></a> * @type {string}
<a name="line113"></a> */
<a name="line114"></a>goog.net.xpc.NixTransport.NIX_HANDLE_MESSAGE = &#39;GCXPC____NIXJS_handle_message&#39;;
<a name="line115"></a>
<a name="line116"></a>/**
<a name="line117"></a> * The name of the create channel method used by the wrapper class
<a name="line118"></a> * when calling the transport.
<a name="line119"></a> * @type {string}
<a name="line120"></a> */
<a name="line121"></a>goog.net.xpc.NixTransport.NIX_CREATE_CHANNEL = &#39;GCXPC____NIXJS_create_channel&#39;;
<a name="line122"></a>
<a name="line123"></a>/**
<a name="line124"></a> * A &quot;unique&quot; identifier that is stored in the wrapper
<a name="line125"></a> * class so that the wrapper can be distinguished from
<a name="line126"></a> * other objects easily.
<a name="line127"></a> * @type {string}
<a name="line128"></a> */
<a name="line129"></a>goog.net.xpc.NixTransport.NIX_ID_FIELD = &#39;GCXPC____NIXVBS_container&#39;;
<a name="line130"></a>
<a name="line131"></a>/**
<a name="line132"></a> * Conducts the global setup work for the NIX transport method.
<a name="line133"></a> * This function creates and then injects into the page the
<a name="line134"></a> * VBScript code necessary to create the NIX wrapper class.
<a name="line135"></a> * Note that this method can be called multiple times, as
<a name="line136"></a> * it internally checks whether the work is necessary before
<a name="line137"></a> * proceeding.
<a name="line138"></a> * @private
<a name="line139"></a> */
<a name="line140"></a>goog.net.xpc.NixTransport.conductGlobalSetup_ = function() {
<a name="line141"></a>  if (window[&#39;nix_setup_complete&#39;]) {
<a name="line142"></a>    return;
<a name="line143"></a>  }
<a name="line144"></a>
<a name="line145"></a>  // Inject the VBScript code needed.
<a name="line146"></a>  var vbscript =
<a name="line147"></a>    // We create a class to act as a wrapper for
<a name="line148"></a>    // a Javascript call, to prevent a break in of
<a name="line149"></a>    // the context.
<a name="line150"></a>    &#39;Class &#39; + goog.net.xpc.NixTransport.NIX_WRAPPER + &#39;\n &#39; +
<a name="line151"></a>
<a name="line152"></a>    // An internal member for keeping track of the
<a name="line153"></a>    // transport for which this wrapper exists.
<a name="line154"></a>    &#39;Private m_Transport\n&#39; +
<a name="line155"></a>
<a name="line156"></a>    // An internal member for keeping track of the
<a name="line157"></a>    // auth token associated with the context that
<a name="line158"></a>    // created this wrapper. Used for validation
<a name="line159"></a>    // purposes.
<a name="line160"></a>    &#39;Private m_Auth\n&#39; +
<a name="line161"></a>
<a name="line162"></a>    // Method for internally setting the value
<a name="line163"></a>    // of the m_Transport property. We have the
<a name="line164"></a>    // isEmpty check to prevent the transport
<a name="line165"></a>    // from being overridden with an illicit
<a name="line166"></a>    // object by a malicious party.
<a name="line167"></a>    &#39;Public Sub SetTransport(transport)\n&#39; +
<a name="line168"></a>    &#39;If isEmpty(m_Transport) Then\n&#39; +
<a name="line169"></a>    &#39;Set m_Transport = transport\n&#39; +
<a name="line170"></a>    &#39;End If\n&#39; +
<a name="line171"></a>    &#39;End Sub\n&#39; +
<a name="line172"></a>
<a name="line173"></a>    // Method for internally setting the value
<a name="line174"></a>    // of the m_Auth property. We have the
<a name="line175"></a>    // isEmpty check to prevent the transport
<a name="line176"></a>    // from being overridden with an illicit
<a name="line177"></a>    // object by a malicious party.
<a name="line178"></a>    &#39;Public Sub SetAuth(auth)\n&#39; +
<a name="line179"></a>    &#39;If isEmpty(m_Auth) Then\n&#39; +
<a name="line180"></a>    &#39;m_Auth = auth\n&#39; +
<a name="line181"></a>    &#39;End If\n&#39; +
<a name="line182"></a>    &#39;End Sub\n&#39; +
<a name="line183"></a>
<a name="line184"></a>    // Returns the auth token to the gadget, so it can
<a name="line185"></a>    // confirm a match before initiating the connection
<a name="line186"></a>    &#39;Public Function GetAuthToken()\n &#39; +
<a name="line187"></a>    &#39;GetAuthToken = m_Auth\n&#39; +
<a name="line188"></a>    &#39;End Function\n&#39; +
<a name="line189"></a>
<a name="line190"></a>    // A wrapper method which causes a
<a name="line191"></a>    // message to be sent to the other context.
<a name="line192"></a>    &#39;Public Sub SendMessage(service, payload)\n &#39; +
<a name="line193"></a>    &#39;Call m_Transport.&#39; +
<a name="line194"></a>    goog.net.xpc.NixTransport.NIX_HANDLE_MESSAGE + &#39;(service, payload)\n&#39; +
<a name="line195"></a>    &#39;End Sub\n&#39; +
<a name="line196"></a>
<a name="line197"></a>    // Method for setting up the inner-&gt;outer
<a name="line198"></a>    // channel.
<a name="line199"></a>    &#39;Public Sub CreateChannel(channel)\n &#39; +
<a name="line200"></a>    &#39;Call m_Transport.&#39; +
<a name="line201"></a>    goog.net.xpc.NixTransport.NIX_CREATE_CHANNEL + &#39;(channel)\n&#39; +
<a name="line202"></a>    &#39;End Sub\n&#39; +
<a name="line203"></a>
<a name="line204"></a>    // An empty field with a unique identifier to
<a name="line205"></a>    // prevent the code from confusing this wrapper
<a name="line206"></a>    // with a run-of-the-mill value found in window.opener.
<a name="line207"></a>    &#39;Public Sub &#39; + goog.net.xpc.NixTransport.NIX_ID_FIELD + &#39;()\n &#39; +
<a name="line208"></a>    &#39;End Sub\n&#39; +
<a name="line209"></a>    &#39;End Class\n &#39; +
<a name="line210"></a>
<a name="line211"></a>    // Function to get a reference to the wrapper.
<a name="line212"></a>    &#39;Function &#39; +
<a name="line213"></a>    goog.net.xpc.NixTransport.NIX_GET_WRAPPER + &#39;(transport, auth)\n&#39; +
<a name="line214"></a>    &#39;Dim wrap\n&#39; +
<a name="line215"></a>    &#39;Set wrap = New &#39; + goog.net.xpc.NixTransport.NIX_WRAPPER + &#39;\n&#39; +
<a name="line216"></a>    &#39;wrap.SetTransport transport\n&#39; +
<a name="line217"></a>    &#39;wrap.SetAuth auth\n&#39; +
<a name="line218"></a>    &#39;Set &#39; + goog.net.xpc.NixTransport.NIX_GET_WRAPPER + &#39; = wrap\n&#39; +
<a name="line219"></a>    &#39;End Function&#39;;
<a name="line220"></a>
<a name="line221"></a>  try {
<a name="line222"></a>    window.execScript(vbscript, &#39;vbscript&#39;);
<a name="line223"></a>    window[&#39;nix_setup_complete&#39;] = true;
<a name="line224"></a>  }
<a name="line225"></a>  catch (e) {
<a name="line226"></a>    goog.net.xpc.logger.severe(
<a name="line227"></a>        &#39;exception caught while attempting global setup: &#39; + e);
<a name="line228"></a>  }
<a name="line229"></a>};
<a name="line230"></a>
<a name="line231"></a>/**
<a name="line232"></a> * The transport type.
<a name="line233"></a> * @type {number}
<a name="line234"></a> * @protected
<a name="line235"></a> */
<a name="line236"></a>goog.net.xpc.NixTransport.prototype.transportType =
<a name="line237"></a>   goog.net.xpc.TransportTypes.NIX;
<a name="line238"></a>
<a name="line239"></a>
<a name="line240"></a>/**
<a name="line241"></a> * Keeps track of whether the local setup has completed (i.e.
<a name="line242"></a> * the initial work towards setting the channel up has been
<a name="line243"></a> * completed for this end).
<a name="line244"></a> * @type {boolean}
<a name="line245"></a> * @private
<a name="line246"></a> */
<a name="line247"></a>goog.net.xpc.NixTransport.prototype.localSetupCompleted_ = false;
<a name="line248"></a>
<a name="line249"></a>/**
<a name="line250"></a> * The NIX channel used to talk to the other page. This
<a name="line251"></a> * object is in fact a reference to a VBScript class
<a name="line252"></a> * (see above) and as such, is in fact a COM wrapper.
<a name="line253"></a> * When using this object, make sure to not access methods
<a name="line254"></a> * without calling them, otherwise a COM error will be thrown.
<a name="line255"></a> * @type {Object}
<a name="line256"></a> * @private
<a name="line257"></a> */
<a name="line258"></a>goog.net.xpc.NixTransport.prototype.nixChannel_ = null;
<a name="line259"></a>
<a name="line260"></a>
<a name="line261"></a>/**
<a name="line262"></a> * Connect this transport.
<a name="line263"></a> */
<a name="line264"></a>goog.net.xpc.NixTransport.prototype.connect = function() {
<a name="line265"></a>  if (this.channel_.getRole() == goog.net.xpc.CrossPageChannel.Role.OUTER) {
<a name="line266"></a>    this.attemptOuterSetup_();
<a name="line267"></a>  } else {
<a name="line268"></a>    this.attemptInnerSetup_();
<a name="line269"></a>  }
<a name="line270"></a>};
<a name="line271"></a>
<a name="line272"></a>
<a name="line273"></a>/**
<a name="line274"></a> * Attempts to setup the channel from the perspective
<a name="line275"></a> * of the outer (read: container) page. This method
<a name="line276"></a> * will attempt to create a NIX wrapper for this transport
<a name="line277"></a> * and place it into the &quot;opener&quot; property of the inner
<a name="line278"></a> * page&#39;s window object. If it fails, it will continue
<a name="line279"></a> * to loop until it does so.
<a name="line280"></a> *
<a name="line281"></a> * @private
<a name="line282"></a> */
<a name="line283"></a>goog.net.xpc.NixTransport.prototype.attemptOuterSetup_ = function() {
<a name="line284"></a>  if (this.localSetupCompleted_) {
<a name="line285"></a>    return;
<a name="line286"></a>  }
<a name="line287"></a>
<a name="line288"></a>  // Get shortcut to iframe-element that contains the inner
<a name="line289"></a>  // page.
<a name="line290"></a>  var innerFrame = this.channel_.iframeElement_;
<a name="line291"></a>
<a name="line292"></a>  try {
<a name="line293"></a>    // Attempt to place the NIX wrapper object into the inner
<a name="line294"></a>    // frame&#39;s opener property.
<a name="line295"></a>    innerFrame.contentWindow.opener =
<a name="line296"></a>      window[goog.net.xpc.NixTransport.NIX_GET_WRAPPER](this, this.authToken_);
<a name="line297"></a>    this.localSetupCompleted_ = true;
<a name="line298"></a>  }
<a name="line299"></a>  catch (e) {
<a name="line300"></a>    goog.net.xpc.logger.severe(
<a name="line301"></a>        &#39;exception caught while attempting setup: &#39; + e);
<a name="line302"></a>  }
<a name="line303"></a>
<a name="line304"></a>  // If the retry is necessary, reattempt this setup.
<a name="line305"></a>  if (!this.localSetupCompleted_) {
<a name="line306"></a>    window.setTimeout(goog.bind(this.attemptOuterSetup_, this), 100);
<a name="line307"></a>  }
<a name="line308"></a>};
<a name="line309"></a>
<a name="line310"></a>/**
<a name="line311"></a> * Attempts to setup the channel from the perspective
<a name="line312"></a> * of the inner (read: iframe) page. This method
<a name="line313"></a> * will attempt to *read* the opener object from the
<a name="line314"></a> * page&#39;s opener property. If it succeeds, this object
<a name="line315"></a> * is saved into nixChannel_ and the channel is confirmed
<a name="line316"></a> * with the container by calling CreateChannel with an instance
<a name="line317"></a> * of a wrapper for *this* page. Note that if this method
<a name="line318"></a> * fails, it will continue to loop until it succeeds.
<a name="line319"></a> *
<a name="line320"></a> * @private
<a name="line321"></a> */
<a name="line322"></a>goog.net.xpc.NixTransport.prototype.attemptInnerSetup_ = function() {
<a name="line323"></a>  if (this.localSetupCompleted_) {
<a name="line324"></a>    return;
<a name="line325"></a>  }
<a name="line326"></a>
<a name="line327"></a>  try {
<a name="line328"></a>    var opener = window.opener;
<a name="line329"></a>
<a name="line330"></a>    // Ensure that the object contained inside the opener
<a name="line331"></a>    // property is in fact a NIX wrapper.
<a name="line332"></a>    if (opener &amp;&amp; goog.net.xpc.NixTransport.NIX_ID_FIELD in opener) {
<a name="line333"></a>      this.nixChannel_ = opener;
<a name="line334"></a>
<a name="line335"></a>      // Ensure that the NIX channel given to use is valid.
<a name="line336"></a>      var remoteAuthToken = this.nixChannel_[&#39;GetAuthToken&#39;]();
<a name="line337"></a>
<a name="line338"></a>      if (remoteAuthToken != this.remoteAuthToken_) {
<a name="line339"></a>        goog.net.xpc.logger.severe(&#39;Invalid auth token from other party&#39;);
<a name="line340"></a>        return;
<a name="line341"></a>      }
<a name="line342"></a>
<a name="line343"></a>      // Complete the construction of the channel by sending our own
<a name="line344"></a>      // wrapper to the container via the channel they gave us.
<a name="line345"></a>      this.nixChannel_[&#39;CreateChannel&#39;](
<a name="line346"></a>        window[goog.net.xpc.NixTransport.NIX_GET_WRAPPER](this,
<a name="line347"></a>                                                          this.authToken_));
<a name="line348"></a>
<a name="line349"></a>      this.localSetupCompleted_ = true;
<a name="line350"></a>
<a name="line351"></a>      // Notify channel that the transport is ready.
<a name="line352"></a>      this.channel_.notifyConnected_();
<a name="line353"></a>    }
<a name="line354"></a>  }
<a name="line355"></a>  catch (e) {
<a name="line356"></a>    goog.net.xpc.logger.severe(
<a name="line357"></a>        &#39;exception caught while attempting setup: &#39; + e);
<a name="line358"></a>    return;
<a name="line359"></a>  }
<a name="line360"></a>
<a name="line361"></a>  // If the retry is necessary, reattempt this setup.
<a name="line362"></a>  if (!this.localSetupCompleted_) {
<a name="line363"></a>    window.setTimeout(goog.bind(this.attemptInnerSetup_, this), 100);
<a name="line364"></a>  }
<a name="line365"></a>};
<a name="line366"></a>
<a name="line367"></a>/**
<a name="line368"></a> * Internal method called by the inner page, via the
<a name="line369"></a> * NIX wrapper, to complete the setup of the channel.
<a name="line370"></a> *
<a name="line371"></a> * @param {Object} channel The NIX wrapper of the
<a name="line372"></a> *  inner page.
<a name="line373"></a> * @private
<a name="line374"></a> */
<a name="line375"></a>goog.net.xpc.NixTransport.prototype.createChannel_ = function(channel) {
<a name="line376"></a>   // Verify that the channel is in fact a NIX wrapper.
<a name="line377"></a>   if (typeof channel != &#39;unknown&#39; ||
<a name="line378"></a>       !(goog.net.xpc.NixTransport.NIX_ID_FIELD in channel)) {
<a name="line379"></a>     goog.net.xpc.logger.severe(&#39;Invalid NIX channel given to createChannel_&#39;);
<a name="line380"></a>   }
<a name="line381"></a>
<a name="line382"></a>   this.nixChannel_ = channel;
<a name="line383"></a>
<a name="line384"></a>   // Ensure that the NIX channel given to use is valid.
<a name="line385"></a>   var remoteAuthToken = this.nixChannel_[&#39;GetAuthToken&#39;]();
<a name="line386"></a>
<a name="line387"></a>   if (remoteAuthToken != this.remoteAuthToken_) {
<a name="line388"></a>     goog.net.xpc.logger.severe(&#39;Invalid auth token from other party&#39;);
<a name="line389"></a>     return;
<a name="line390"></a>   }
<a name="line391"></a>
<a name="line392"></a>   // Indicate to the CrossPageChannel that the channel is setup
<a name="line393"></a>   // and ready to use.
<a name="line394"></a>   this.channel_.notifyConnected_();
<a name="line395"></a>};
<a name="line396"></a>
<a name="line397"></a>/**
<a name="line398"></a> * Internal method called by the other page, via the NIX wrapper,
<a name="line399"></a> * to deliver a message.
<a name="line400"></a> * @param {string} serviceName The name of the service the message is to be
<a name="line401"></a> *   delivered to.
<a name="line402"></a> * @param {string} payload The message to process.
<a name="line403"></a> * @private
<a name="line404"></a> */
<a name="line405"></a>goog.net.xpc.NixTransport.prototype.handleMessage_ =
<a name="line406"></a>    function(serviceName, payload) {
<a name="line407"></a>
<a name="line408"></a>  function deliveryHandler() {
<a name="line409"></a>    this.channel_.deliver_(serviceName, payload);
<a name="line410"></a>  }
<a name="line411"></a>
<a name="line412"></a>  window.setTimeout(goog.bind(deliveryHandler, this), 1);
<a name="line413"></a>};
<a name="line414"></a>
<a name="line415"></a>
<a name="line416"></a>/**
<a name="line417"></a> * Sends a message.
<a name="line418"></a> * @param {string} service The name of the service the message is to be
<a name="line419"></a> *   delivered to.
<a name="line420"></a> * @param {string} payload The message content.
<a name="line421"></a> */
<a name="line422"></a>goog.net.xpc.NixTransport.prototype.send = function(service, payload) {
<a name="line423"></a>  // Verify that the NIX channel we have is valid.
<a name="line424"></a>  if (typeof(this.nixChannel_) !== &#39;unknown&#39;) {
<a name="line425"></a>    goog.net.xpc.logger.severe(&#39;NIX channel not connected&#39;);
<a name="line426"></a>  }
<a name="line427"></a>
<a name="line428"></a>  // Send the message via the NIX wrapper object.
<a name="line429"></a>  this.nixChannel_[&#39;SendMessage&#39;](service, payload);
<a name="line430"></a>};
<a name="line431"></a>
<a name="line432"></a>
<a name="line433"></a>/**
<a name="line434"></a> * Disposes of the transport.
<a name="line435"></a> */
<a name="line436"></a>goog.net.xpc.NixTransport.prototype.disposeInternal = function() {
<a name="line437"></a>  goog.net.xpc.NixTransport.superClass_.disposeInternal.call(this);
<a name="line438"></a>  this.nixChannel_ = null;
<a name="line439"></a>};
</pre>


</body>
</html>
